#定义一个类
# class A:
#     def __init__(self):
#         self.n = 1
#     def print_info(self):
#         print(self.n)


#创建一个子类继承A类为父类
# class B(A):
#     pass
#
# if __name__ == '__main__':
#     #实例化B类
#     b = B()
#     print(b.n)
#     b.print_info()

#1.师父类
class Master(object):
    def __init__(self):
        self.kongfu = "[五香煎饼果子配方]"
        #私有属性
        self.__money = 200

    def make_cake(self):
        print(f"运用{self.kongfu}制作煎饼果子")
# #2徒弟类
# # class Prentice(Master):
# #     pass
    #私有方法
    def __info_print(self):
        print(self.__money)
    #定义一个方法查看私有属性
    def get_money(self):
        #调用私有方法
        self.__info_print()
    #修改私有属性
    def set_money(self,n):
        if n > 0:
            self.__money += n
        else:
            print("乖乖存钱，只存不许取")

class Pretice():
    pass
# #3.创建对象xiaoming
# xiaoming = Prentice()
# #4.对象访问实例属性
# print(xiaoming.kongfu)
# #5.对象调用实例方法
# xiaoming.make_cake()
if __name__ == '__main__':

     xiaoming = Pretice()
     xiaogang = Master()
     xiaogang.get_money()
     xiaogang.set_money(100)
     xiaogang.set_money(-100)


